####################### c@@- [ Environment Variables ]#######################
set -x EDITOR vim

# .@@. paths
set -x VIRTUALFISH_HOME ~/Environments/python
set -x GOPATH           ~/Environments/gopath
set -x CONDA_PATH       ~/miniconda3
set -x RUST_PATH        ~/.cargo

if test -n (which ruby)
  set -x RUBY_VER      (ruby -v | sed -n 1p | sed 's/.*\(2\.[0-9]\.[0-9]\).*/\1/p')
  set -x GEM_PATH       ~/.gem/ruby/$RUBY_VER
end

# .@@. mirrors
set -x SASS_BINARY_SITE http://npm.taobao.org/mirrors/node-sass

if test -e $GOPATH
  set -x PATH $GOPATH/bin $PATH
end
if test -e $CONDA_PATH
  set -x PATH $CONDA_PATH/bin $PATH
end
if test -e $RUST_PATH
  set -x PATH $RUST_PATH/bin $PATH
end
if test -e /opt/local/bin
  set -x PATH /opt/local/bin $PATH
end
if set -q GEM_PATH
  set -x PATH $GEM_PATH/bin $PATH
end

set -x PATH ~/.local/bin $PATH

############################# c@@- [ Packages ]#############################
# .@@. fisher
if not functions -q fisher
  set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
  curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish
  fish -c fisher
end

# .@@. done
set -U __done_min_cmd_duration 5000       # default: 5000 ms
set -U __done_exclude 'git (?!push|pull)' # default: all git commands, except push and pull. accepts a regex.

############################## c@@- [ Aliases ]##############################
function tmux --description "support 256color vim"
  env TERM=screen-256color tmux $argv
end

function rvm-init
  bass source ~/.rvm/scripts/rvm
end

function virtualfish-init
  eval (python -m virtualfish)
end

function emacsnw --description "emacs -nw"
  env TERM=xterm-256color emacs -nw $argv
end

function nvm --description 'bass nvm wrapper'
  if test -f ~/.nvm/nvm.sh
    bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
  end
end

function gem_install --description "install gems to user"
  if set -q GEM_PATH
    command gem install $argv --install-dir $GEM_PATH 
  end
end

function vnc-tunnel --description "vnc client connect tunnel"
  # ssh -L 5901:127.0.0.1:5901 -N -f -l fosonmeng 192.168.10.140
end

function urxvt --description "urxvt 256 color"
  if test -n (which urxvt256c)
    urxvt256c $argv
  else
    command urxvt $argv
  end
end

function cygpath -d "get cygpath of windows path"
  command /bin/cygpath -a -p $argv
end

function cygcd -d "cd to windows path in cygwin"
  cd (cygpath $argv)
end

switch (uname)
############################# c@@- [ GNU Linux ]#############################
case Linux
  set -x PATH /usr/sbin $PATH
  set -x VISUAL gvim
  # .@@. done
  set -U __done_notification_command "notify-send 'DONE!' 'From fish plugin(done), \nwhen something with a long-run done.' -t 10000"

############################# c@@- [ Mac OS X ]#############################
case Darwin
  set -x VISUAL mvim
  # llvm
  set -gx LDFLAGS  "-L/usr/local/opt/llvm/lib -L/usr/local/opt/openblas/lib -L/usr/local/opt/readline/lib"
  set -gx CPPFLAGS "-I/usr/local/opt/llvm/include -I/usr/local/opt/openblas/include -I/usr/local/opt/readline/include"
  set -gx PKG_CONFIG_PATH "/usr/local/opt/readline/lib/pkgconfig"
  # mactex
  set -x PATH /usr/local/texlive/2018basic/bin/x86_64-darwin $PATH
  # .@@. done
  set -U __done_notification_command "terminal-notifier -title 'DONE!' -subtitle 'From fish plugin(done)' -message 'when something with a long-run done.'"

case FreeBSD NetBSD DragonFly
case '*'

############################## c@@- [ CYGWIN ]##############################
end

set -l config_dir (dirname (status filename))
if test -f $config_dir/init-local.fish
  source $config_dir/init-local.fish
end


# .@@v vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab :
